package com.itheima.create;

public class ArrayDemo1 {
    public static void main(String[] args) {
        // 目标：掌握数组的定义方式：静态初始化数组。
        // 格式： 数据类型[] 数组名 = new 数据类型[]{元素1, 元素2, 元素3, ...}
        int[] ages = new int[]{12, 24, 36};
        double[] scores = new double[]{99.5, 100, 59.5, 88};
        System.out.println(ages);
        System.out.println(scores);

        // 简化格式： 数据类型[] 数组名 = {元素1, 元素2, 元素3, ...}
        int[] ages2 = {12, 24, 36};
        int ages22[] = {12, 24, 36};

        double[] scores2 = {99.5, 100, 59.5, 88};
        double scores22[] = {99.5, 100, 59.5, 88};

        // 什么类型的数组只能存放什么类型的数据
        // String[] names = new String[]{"陈宏", "罗翔", "王程", 666};

        int[] temp = {1,2,3,4,5,6};
        String[] name = {"A","B","C","D","E","F"};
        for (int i = 0; i < temp.length; i++) {
            System.out.println(temp[i]);
        }

        for (int i = 0; i < name.length; i++) {
            System.out.println(name[i]);
        }
    }
}
